]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
volume: Show overamplified icon when in overdrive
authorDidier Roche <didrocks@ubuntu.com>
Fri, 9 Feb 2018 14:10:16 +0000 (15:10 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 31 Jul 2018 18:14:15 +0000 (18:14 +0000)
Show an overamplified volume icon if volume is louder the max normalized one.
Use a similar logic as gnome-settings-daemon to delimit values, restricted
to output.
The purpose is to help users remember that visiting some websites or
using some apps can get LOUD.

https://bugzilla.gnome.org/show_bug.cgi?id=790280.

js/ui/status/volume.js

index b337e752d9cafb6c776c23874e73057171c249c8..00af791a6ee4772744edaa41c8c98dc22e2bed1b 100644 (file)
@@ -158,17 +158,24 @@ var StreamSlider = new Lang.Class({
         if (!this._stream)
             return null;
 
+        let icons = ["audio-volume-muted-symbolic",
+                     "audio-volume-low-symbolic",
+                     "audio-volume-medium-symbolic",
+                     "audio-volume-high-symbolic",
+                     "audio-volume-overamplified-symbolic"];
+
         let volume = this._stream.volume;
+        let n;
         if (this._stream.is_muted || volume <= 0) {
-            return 'audio-volume-muted-symbolic';
+            n = 0;
         } else {
-            let n = Math.floor(3 * volume / this._control.get_vol_max_norm()) + 1;
-            if (n < 2)
-                return 'audio-volume-low-symbolic';
-            if (n >= 3)
-                return 'audio-volume-high-symbolic';
-            return 'audio-volume-medium-symbolic';
+            n = Math.ceil(3 * volume / this._control.get_vol_max_norm());
+            if (n < 1)
+                n = 1;
+            else if (n > 3)
+                n = 4;
         }
+        return icons[n];
     },
 
     getLevel() {